function SaveCard_onclick(){
	var  pp
	pp = rdcard.ExportBMP("D:\\"); 
	if(pp==0)
        {
	    document.getElementsByName("tResult")[0].value="保存成功";
        }
        else
        {	
            document.getElementsByName("tResult")[0].value="保存失败: "+pp;
        }
	}

	function myopen_onclick(){
		var  pp ;
		pp=rdcard.openport();
	        //alert(pp);
		if(pp==0)
	        {
				return true;
				//alert("打开端口成功!");
			 	//document.getElementsByName("tResult")[0].value="openport成功";
	        }
	        else
	        {	
	        	return false;
	            //document.getElementsByName("tResult")[0].value="openport失败: "+pp;
	        }	
    }	
	    
	function myclose_onclick(){
		alert("关闭端口");
	var  pp
	pp=rdcard.closeport();
	if(pp==0)
        {
	    document.getElementsByName("tResult")[0].value="closeport成功";
        }
        else
        {	
            document.getElementsByName("tResult")[0].value="closeport失败: "+pp;
        }		
	}
    
	
	function Unload(){
		MyClose_onclick();
		alert("Page is Close");
	}

	function endread_onclick(){
	var  pp
	pp=rdcard.endread();
	if(pp==0)
        {
	    document.getElementsByName("tResult")[0].value="endread成功";
        }
        else
        {	
            document.getElementsByName("tResult")[0].value="endread失败: "+pp;
        }		
	}

	function handread_onclick(){ 
		
	var  pp
	pp=rdcard.readcard();
	if(pp==0)
        {
	   // document.getElementsByName("tResult")[0].value="readcard成功";
            //showjpg_onclick();
        }
        else
        {	
           // document.getElementsByName("tResult")[0].value="readcard失败: "+pp;
        }
	}
	
	//开始读取身份证信息
	function Idcard(){
		//验证端口是否打开
		var openFlag = myopen_onclick();
		
		if (!openFlag) {
			alert("打开端口失败");
			return false;
		}
		
		var  pp
		//重复读取
		//pp=rdcard.ReadCard2();
		
		//手动触发读取
		pp = rdcard.ReadCard();
		if(pp==0) {
				console.log("ReadCard2成功");
		    	//document.getElementsByName("tResult")[0].value="ReadCard2成功";
				return true;
	    } else {
	    	toastr.warning('请重新读取身份证或到人工窗口办理!');
	        return false;
	    }
	}
	
	function read3_onclick(){
		
	var  pp
	pp=rdcard.ReadCard3();
	if(pp==0)
        {
	    document.getElementsByName("tResult")[0].value="ReadCard3成功";
        }
        else
        {	
            document.getElementsByName("tResult")[0].value="ReadCard3失败: "+pp;
        }
	}
    
	function ReadsNum_onclick(){
	var  pp
	pp = rdcard.ReadSecurityNum();
	if(pp==0)
        {
            document.getElementsByName("tsNum")[0].value=rdcard.SecurityNum;	
            document.getElementsByName("tResult")[0].value=rdcard.sResultMsg;
        }
        else
        {
            document.getElementsByName("tsNum")[0].value="读模块号码失败";	
            document.getElementsByName("tResult")[0].value="读模块号码失败: "+pp;
        }
	}
	

	function showjpgIE6(){
        //alert('读照片成功');
        document.getElementsByName("photo")[0].src = "file:///C|/null.JPEG";

	if(rdcard.PhotoPath == "")  
	  document.getElementsByName("photo")[0].src = "file:///C|/null.JPEG";
	else 	
	  document.getElementsByName("photo")[0].src = rdcard.PhotoPath	;	
    }
	function showjpgIE8(){
        //alert('读照片成功');
        document.all['photo'].src  = 'data:image/jpeg;base64,' + rdcard.JPGBuffer;	
    }

   function getinfo_onclick(){
	var  r1,r2;
	/*document.getElementsByName("tName")[0].value=rdcard.NameS;
	document.getElementsByName("tNameL")[0].value=rdcard.NameL;
	document.getElementsByName("tSex")[0].value=rdcard.Sex;
	document.getElementsByName("tSexL")[0].value=rdcard.SexL;
	document.getElementsByName("tFolk")[0].value=rdcard.Nation;
	document.getElementsByName("tFolkL")[0].value=rdcard.NationL;
	document.getElementsByName("tBirth")[0].value=rdcard.Born;
	document.getElementsByName("tBirthL")[0].value=rdcard.BornL;
	document.getElementsByName("tcardID")[0].value=rdcard.CardNo;
	document.getElementsByName("tAddr")[0].value=rdcard.Address;
	document.getElementsByName("tnewAddr")[0].value=rdcard.newAddress;
	document.getElementsByName("tIssue")[0].value =rdcard.Police;
	document.getElementsByName("tBeginEnd")[0].value=rdcard.Activity;
	document.getElementsByName("tBeginEndL")[0].value=rdcard.ActivityL;
	
	document.getElementsByName("jroot")[0].value=rdcard.JPGfile;
	document.getElementsByName("broot")[0].value=rdcard.BMPfile;
	document.getElementsByName("jbuff")[0].value=rdcard.JPGBuffer;
	document.getElementsByName("bbuff")[0].value=rdcard.BMPBuffer;
	
    document.getElementsByName("Fchar1")[0].value=rdcard.FGchar1;
    document.getElementsByName("Fchar2")[0].value=rdcard.FGchar2;
	document.getElementsByName("tCardType")[0].value=rdcard.CardType;*/
	
	//姓名
	$("#span_name").text(rdcard.NameL);
	
	//性别
	$("#span_sex").text(rdcard.SexL);

	//民族
	$("#span_nation").text(rdcard.NationL);
	
	//出生
	$("#span_birthday").text(rdcard.BornL);
	
	//住址
	$("#span_address").text(rdcard.Address);
	
	//公民身份证号码
	$("#span_idcard").text(rdcard.CardNo);
	
	document.getElementById("dispHead").src = 'data:image/jpeg;base64,' + rdcard.BMPBuffer;
	
	//alert(rdcard.CardNo);
	
	console.log("goinfo_onclick");
	
	if(rdcard.bHaveCard == "1")
	{
		if(rdcard.CardType == "I")
		{
			//document.getElementsByName("tCardT")[0].value="外国人永久居留证";
			return true;
		}
		else
		{
			//document.getElementsByName("tCardT")[0].value="二代身份证";
			return true;
		}
	} else {
		alert("当前卡片可能不是身份证，请将身份证放到读卡器上！");
		return false;
		//document.getElementsByName("tCardT")[0].value="";
	}    
	
}


	function savepath_onclick(){
	rdcard.strSavePath= "c:\\aa";
	document.getElementsByName("tResult")[0].value="路径设置成功";
	}


	function MyClear_onclick(){
        var  pp		
        pp = rdcard.ClearAll();
        getinfo_onclick();
        document.getElementsByName("tsNum")[0].value="";
	if(pp==0)
        {
	    document.getElementsByName("tResult")[0].value="清空成功";
        }
        else
        {	
            document.getElementsByName("tResult")[0].value="清空失败: "+pp;
        }
	}


	function window_onUnload(){
		  rdcard.DeleteOutputFile();
		  rdcard.DeleteAllPicture();
	}  